-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error: cannot use 'try' with exceptions disabled in Win LLVM Clang #4208
Conversation
Other GCC related macros undefined in LLVM Clang on Windows: #define __GCC_ASM_FLAG_OUTPUTS__ 1
< #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
< #define __GCC_ATOMIC_INT_LOCK_FREE 2
< #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
< #define __GCC_ATOMIC_LONG_LOCK_FREE 2
< #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
< #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
< #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
< #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
#define __GCC_CONSTRUCTIVE_SIZE 64
#define __GCC_DESTRUCTIVE_SIZE 64
< #define __GCC_HAVE_DWARF2_CFI_ASM 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
< #define __GLIBCXX_BITSIZE_INT_N_0 128
< #define __GLIBCXX_TYPE_INT_N_0 __int128
< #define __GNUC_GNU_INLINE__ 1
< #define __GNUC_MINOR__ 2
< #define __GNUC_PATCHLEVEL__ 1
< #define __GNUC__ 4
< #define __GNUG__ 4
< #define __GXX_ABI_VERSION 1002
< #define __GXX_EXPERIMENTAL_CXX0X__ 1
< #define __GXX_RTTI 1
< #define __GXX_WEAK__ 1
#define __INT16_C_SUFFIX__ |
clang-cl seems to define |
@mwinterb You are right, Clang uses |
ae23fe5
to
67bb7f5
Compare
Please apply clang-format. |
include/fmt/base.h
Outdated
@@ -146,6 +146,8 @@ | |||
// Use the provided definition. | |||
#elif defined(__GNUC__) && !defined(__EXCEPTIONS) | |||
# define FMT_USE_EXCEPTIONS 0 | |||
#elif defined(__clang__) && (!defined(__cpp_exceptions) || __cpp_exceptions < 199711L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why they check against 199711L?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK. As I mentioned, this is how Clang does that C++ exceptions check.
Maybe very older clang set it to some lower value and __cpp_exceptions < 199711L
can be removed since such old clang cannot be used with {fmt}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing the __cpp_exceptions < 199711L
part then if it works in your environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works.
67bb7f5
to
0557417
Compare
Fixes fmtlib#4207. LLVM Clang on Windows does not define `__GNUC__`. The preprocessor falls to `#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS` with `_HAS_EXCEPTIONS 1` defined in vcruntime.h:104.
0557417
to
1f14cb0
Compare
Fixes #4207.
LLVM Clang on Windows does not define
__GNUC__
. The preprocessor falls to#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS
with_HAS_EXCEPTIONS 1
defined in vcruntime.h:104.